package com.piece.module.spider.model;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.*;

@Data
@Entity
@NoArgsConstructor
@Table(name = "sp_flow_notice")
@ApiModel(value = "爬虫通知表:sp_flow_notice")
public class FlowNotice {

	/**
	 * 对应：{@link SpiderFlow 主键}
	 */
	@Id
	@Column(name = "id", length = 11)
	@ApiModelProperty(value = "主键")
	private Long id;

	@Column(name = "recipients")
	@ApiModelProperty(value = "收件人", notes = "多个收件人用 , 隔开")
	private String recipients;

	/**
	 * 查看：{@link com.piece.module.spider.support.FlowNoticeWay}
	 */
	@Column(name = "notice_way")
	@ApiModelProperty(value = "通知方式")
	private String noticeWay;

	@Column(name = "start_notice")
	@ApiModelProperty(value = "流程开始通知状态", notes = "1=开启通知, 0=关闭通知")
	private String startNotice;

	@Column(name = "exception_notice")
	@ApiModelProperty(value = "流程异常通知状态", notes = "1=开启通知, 0=关闭通知")
	private String exceptionNotice;

	@Column(name = "end_notice")
	@ApiModelProperty(value = "流程结束通知状态", notes = "1=开启通知, 0=关闭通知")
	private String endNotice;

	@Transient
	private final String START_FLAG = "1";

	public boolean judgeStartNotice() {
		if (START_FLAG.equals(this.startNotice)) {
			return true;
		}
		return false;
	}

	public boolean judgeExceptionNotice() {
		if (START_FLAG.equals(this.exceptionNotice)) {
			return true;
		}
		return false;
	}

	public boolean judgeEndNotice() {
		if (START_FLAG.equals(this.endNotice)) {
			return true;
		}
		return false;
	}
}
